home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Night Owl 6
/
Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso
/
038a
/
bas_int1.zip
/
WHAT_DRV.BAS
< prev
Wrap
BASIC Source File
|
1991-03-04
|
2KB
|
53 lines
'====================================================================
' -=[CURDIR.BAS]=-
' Date : 27-Feb-91
' From : Rick Cooper
'Subject : Re: drive spec
'
' This Function Will Return The Current Path With A Complete Path Spec
' Including Drive And Trailing "\"
' If You Don't Want The trailing "\" Then Use A Left$ Statement To
' Remove It... E.G. Dir$ = Left$(CurrentDir$,Len(CurrentDir$) - 1)
' Don't Forget To Place '$INCLUDE:'QB.BI' At The Top of your Program
' Rick Cooper
'===================================================================
FUNCTION CurrentDir$
DIM InRegs AS RegTypeX, OutRegs AS RegTypeX
InRegs.Ax = &H1900 'Use Dos Function To Get
CALL INTERRUPTX(&H21, InRegs, OutRegs) 'Current Drive
Drive% = (OutRegs.Ax AND &HFF) + 1 'Function Returns 0 Based
'Drive Number And Next
'Function needs A 1 Based
'Number So We Add 1 To Result
Drive$ = CHR$(64 + Drive%) 'Create String Representation
'In Uppercase, Of Current
'Drive Number
Directory$ = SPACE$(64) 'Create Scratch Buffer
InRegs.Ax = (256 * &H47) + 0 'Load Function Number
InRegs.Dx = (256 * 0) + Drive% 'Load Drive Number
InRegs.Ds = VARSEG(Directory$) 'Pointer To A 64 Byte
InRegs.Si = SADD(Directory$) 'Scratch Buffer
CALL INTERRUPTX(&H21, InRegs, OutRegs) 'Call Dos Int. 21 Func. 47
spot = INSTR(Directory$, CHR$(0)) 'Function Returns An ASCIIZ
IF spot <> 0 THEN 'String And We Don't Want The
Directory$ = LEFT$(Directory$, spot - 1) 'Terminating Null Character
END IF 'So This Removes It And
'Trailing Spaces
IF LEN(Directory$) > 1 THEN 'If It Isn't The Root Then
'We Add A Trailing "\"
CurrentDir$ = Drive$ + ":\" + Directory$ + "\"
ELSE 'If It Is The Root We Don't
CurrentDir$ = Drive$ + ":\" + RTRIM$(LTRIM$(Directory$))
END IF 'Done!
END FUNCTION